// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "DataAsset/CharacterClassInfo.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "AuraAbilitySystemBPLibrary.generated.h"

struct FGameplayEffectContextHandle;
class UAbilitySystemComponent;
class UAttributeMenuWidgetController;
class UOverlayWidgetController;
/**
 * 蓝图和C++调用的能力系统工具库
 */
UCLASS()
class AURA_API UAuraAbilitySystemBPLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

public:

	// ----------------------------------------------------------------------------------------------------------------
	//	UI 相关
	// ----------------------------------------------------------------------------------------------------------------

	/** 获取Overlay控制器 */
	UFUNCTION(BlueprintPure, Category="AuraAbilitySystemLibrary|WidgetController")
	static UOverlayWidgetController* GetOverWidgetController(const UObject* WorldContextObject);

	/** 获取属性菜单控制器 */
	UFUNCTION(BlueprintPure, Category="AuraAbilitySystemLibrary|WidgetController")
	static UAttributeMenuWidgetController* GetAttributeMenuWidgetController(const UObject* WorldContextObject);

	// ----------------------------------------------------------------------------------------------------------------
	//	初始化相关
	// ----------------------------------------------------------------------------------------------------------------

	/** 获取角色类默认信息 */
	UFUNCTION(BlueprintCallable, Category="AuraAbilitySystemLibrary|CharacterClassDefaults")
	static UCharacterClassInfo* GetCharacterClassDefaultInfo(const UObject* WorldContextObject);

	/** 通过GE初始化ASC默认属性 */
	static void InitDefaultAttributes(
		const UObject* WorldContextObject, ERoleClass RoleClass, float Level, UAbilitySystemComponent* ASC
	);

	/** 启动时,授予ASC能力 */
	static void GiveStartupAbilities(
		const UObject* WorldContextObject, UAbilitySystemComponent* ASC, ERoleClass RoleClass
	);

	// ----------------------------------------------------------------------------------------------------------------
	//	GEContextHandle相关
	// ----------------------------------------------------------------------------------------------------------------

	/** 给定GEContextHandle检查格挡标志位 */
	UFUNCTION(BlueprintPure, Category="AuraAbilitySystemLibrary|GEContextHandle")
	static bool IsBlockedHit(const FGameplayEffectContextHandle& EffectContextHandle);

	/** 给定GEContextHandle检查暴击标志位 */
	UFUNCTION(BlueprintPure, Category="AuraAbilitySystemLibrary|GEContextHandle")
	static bool IsCriticalHit(const FGameplayEffectContextHandle& EffectContextHandle);

	/** 给定GEContextHandle设置格挡标志位 */
	UFUNCTION(BlueprintCallable, Category="AuraAbilitySystemLibrary|GEContextHandle")
	static void SetIsBlockedHit(
		UPARAM(ref) FGameplayEffectContextHandle& EffectContextHandle, const bool InbIsBlockedHit
	);

	/** 给定GEContextHandle设置暴击标志位 */
	UFUNCTION(BlueprintCallable, Category="AuraAbilitySystemLibrary|GEContextHandle")
	static void SetIsCriticalHit(
		UPARAM(ref) FGameplayEffectContextHandle& EffectContextHandle, const bool InbIsCriticalHit
	);

	// ----------------------------------------------------------------------------------------------------------------
	//	战斗相关
	// ----------------------------------------------------------------------------------------------------------------

	/** 获取所有在指定半径内的玩家 */
	UFUNCTION(BlueprintCallable, Category="AuraAbilitySystemLibrary|GameplayMechanics")
	static void GetLivePlayersWithinRadius(
		const UObject* WorldContextObject, TArray<AActor*>& OutOverlappingActors, const TArray<AActor*>& ActorsToIgnore,
		const FVector& Origin, float Radius
	);

	/** 判断是否是友方 */
	UFUNCTION(BlueprintPure, Category="AuraAbilitySystemLibrary|GameplayMechanics")
	static bool IsFriendly(const AActor* ActorA, const AActor* ActorB);

	/** 根据角色类和等级获取XP奖励 */
	static int32 GetXPRewardForClassAndLevel(const UObject* WorldContextObject, ERoleClass RoleClass, int32 Level);
	
	// ----------------------------------------------------------------------------------------------------------------
	//	其他
	// ----------------------------------------------------------------------------------------------------------------

};
